home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / aros / source / exec / messages / src / createmsgport.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-16  |  1.9 KB  |  89 lines

  1. /*
  2.     $Id$
  3.     $Log$
  4.     Desc:
  5.     Lang: english
  6. */
  7. #include "exec_intern.h"
  8. #include <exec/memory.h>
  9. #include <exec/ports.h>
  10. #include <exec/execbase.h>
  11. #include <aros/libcall.h>
  12.  
  13. /*****************************************************************************
  14.  
  15.     NAME */
  16.     #include <clib/exec_protos.h>
  17.  
  18.     __AROS_LH0(struct MsgPort *, CreateMsgPort,
  19.  
  20. /*  SYNOPSIS */
  21.     /* void */
  22.  
  23. /*  LOCATION */
  24.     struct ExecBase *, SysBase, 111, Exec)
  25.  
  26. /*  FUNCTION
  27.     Create a new message port. A signal will be allocated and the message
  28.     port set to signal you task
  29.  
  30.     INPUTS
  31.  
  32.     RESULT
  33.     Pointer to messageport structure
  34.  
  35.     NOTES
  36.  
  37.     EXAMPLE
  38.  
  39.     BUGS
  40.  
  41.     SEE ALSO
  42.  
  43.     INTERNALS
  44.  
  45.     HISTORY
  46.     29-10-95    digulla automatically created from
  47.                 exec_lib.fd and clib/exec_protos.h
  48.     17-12-95    digulla Incorporated code by Matthias Fleischner
  49.  
  50. *****************************************************************************/
  51. {
  52.     __AROS_FUNC_INIT
  53.     struct MsgPort *ret;
  54.  
  55.     /* Allocate memory for struct MsgPort */
  56.     ret=(struct MsgPort *)AllocMem(sizeof(struct MsgPort),MEMF_PUBLIC|MEMF_CLEAR);
  57.     if(ret!=NULL)
  58.     {
  59.     BYTE sb;
  60.  
  61.     /* Allocate a signal bit */
  62.     sb=AllocSignal(-1);
  63.     if(sb!=-1)
  64.     {
  65.         /* Initialize messageport structure. First set signal bit. */
  66.         ret->mp_SigBit=sb;
  67.  
  68.         /* Clear the list of messages */
  69.         ret->mp_MsgList.lh_Head=(struct Node *)&ret->mp_MsgList.lh_Tail;
  70.         /* ret->mp_MsgList.lh_Tail=NULL; */
  71.         ret->mp_MsgList.lh_TailPred=(struct Node *)&ret->mp_MsgList.lh_Head;
  72.  
  73.         /* Set port to type 'signalling' */
  74.         ret->mp_Flags=PA_SIGNAL;
  75.  
  76.         /* Finally set task to send the signal to. */
  77.         ret->mp_SigTask=SysBase->ThisTask;
  78.  
  79.         /* Now the port is ready for use. */
  80.         return ret;
  81.     }
  82.     /* Couldn't get the signal bit. Free the memory. */
  83.     FreeMem(ret,sizeof(struct MsgPort));
  84.     }
  85.     /* function failed */
  86.     return NULL;
  87.     __AROS_FUNC_EXIT
  88. } /* CreateMsgPort */
  89.